#include "Logger.h"

namespace Utility
{
    namespace LoggerLib
    {
        CLogger::CLogger()
        {
            m_bInitialized = false;
        }

        CLogger::~CLogger()
        {

        }

        bool CLogger::Initialize(unsigned long dwLevelMask /* = ALL_LEVEL */, unsigned long dwExecutorMask /* = FILE_Executor */, const wstring& strLogFilePath /* = L"DefaultLog" */)
        {
            m_bInitialized = true;

            m_LogManager.SetLogLevel(dwLevelMask);
            m_LogManager.SetLogExecutorFlag(dwExecutorMask);

            m_LogManager.SetLogFilePath(strLogFilePath);
            
            m_LogManager.StartAllExecutors();

            return true;
        }

        void CLogger::Terminate()
        {
        //    m_LogManager.ClearAllExecutors();
        }

        void CLogger::SetLogFilePath(const CString &strFilePath)
        {

        }

        void CLogger::SetLevel(unsigned long dwLevelMask)
        {

        }

        unsigned long CLogger::GetLevelMask() const
        {
            return 1;
        }

        void CLogger::SetExecutor(unsigned long dwExecutorMask)
        {

        }

        unsigned long CLogger::GetExecutorMask() const
        {
            return 1;
        }

        int CLogger::Log(ELOGLEVEL eLevel, ELOGMODULE eModule, const wstring& strLog)
        {
            return m_LogManager.Log(eLevel, eModule, strLog);
        }

        int CLogger::Log(ELOGLEVEL eLevel, ELOGMODULE eModule, TCHAR* strFormat, ...)
        {
            va_list va;
            va_start(va, strFormat);
            TCHAR szBuf[1024];
            ZeroMemory(szBuf, 1024);

            vswprintf_s(szBuf, strFormat, va);
            return m_LogManager.Log(eLevel, eModule, wstring(szBuf));
        }

    }
}
